package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/2/16 20:59
 * @since v1.0
 */
@Getter
public enum CommunicatePlanNotifyTypeEnum {
    // 访客计划提醒类型
    NO_NOTIFY(0,"noNotify", "enum.communicatePlanNotifyType.alias.no_notify"),


    ADVANCE_ONE_QUARTER_HOUR(1,"advanceOneQuarterHour", "enum.communicatePlanNotifyType.alias.advance_one_quarter_hour"),


    ADVANCE_ONE_HOUR(2,"advanceOneHour", "enum.communicatePlanNotifyType.alias.advance_one_hour"),


    ADVANCE_ONE_DAY(3,"advanceOneDay", "enum.communicatePlanNotifyType.alias.advance_one_day"),


    ADVANCE_THREE_DAY(4,"advanceThreeDay", "enum.communicatePlanNotifyType.alias.advance_three_day"),


    ADVANCE_ONE_WEEK(5,"advanceOneWeek", "enum.communicatePlanNotifyType.alias.advance_one_week"),


    CUSTOM_TIME(6,"customTime", "enum.communicatePlanNotifyType.alias.custom_time"),


    UNKNOW(404,"unkonw", "enum.communicatePlanNotifyType.alias.unknow"),
    ;
    private Integer code;
    private String attr;
    private String alias;

    CommunicatePlanNotifyTypeEnum(Integer code, String attr, String alias) {
        this.code = code;
        this.attr = attr;
        this.alias = alias;
    }

    public static CommunicatePlanNotifyTypeEnum getByCode(Integer code){
        for (CommunicatePlanNotifyTypeEnum statusEnum : values()){
            if (Objects.equals(statusEnum.code,code)){
                return statusEnum;
            }
        }
        return UNKNOW;
    }

    public String getAlias() {
        return I18nMessageUtil.getMessage(alias);
    }
}
